<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function fun() {
            this.a = 0;
            this.b = function() {
                alert(this.a);
            }
        }
        fun.prototype = {
            b: function() {
                this.a = 20;
                alert(this.a);
            },
            c: function() {
                this.a = 30;
                alert(this.a);
            }
        };
        var my_fun = new fun();
        my_fun.b(); // '0' alert弹出的结果都是字符串类型
        my_fun.c(); // '30' --> my_fun.__proto__.c()函数里面的this为my_fun
        console.log(fun.prototype.constructor == Object); // true
        console.log('-------------------');
        var my_fun2 = new fun;
        console.log(my_fun2.a); // 0
        my_fun2.__proto__.c(); // 注意这里的this并不是my_fun2 而是 =>this:my_fun2.proto__
        //my_fun2.__proto__.a = 30(当前实例通过原型链在类的公有属性上增加了一个a:30)
        console.log(my_fun2.a); //0
        console.log(my_fun.__proto__.a); // 30
        /* 
            1.alert 0 
            2.alert 30
            3.console true
            4.console '---------'
            5.console 0
            6.alert 30
            7.console 0
            8.console 30
         */
    </script>
</body>

</html>